<?php
namespace App\Common\Tools;
/**
 * Created by PhpStorm.
 * User: shaowei
 * Date: 2018/10/16
 * Time: 10:45
 */

trait returnJson
{
    //错误提示
    protected function errorReturn($data = [],$error_code=500,$msg = 'error'){
        return response()->json([
            'error_code'=>$error_code,
            'data'=>$data,
            'msg'=>$msg,
            'error_msg' => empty($data['error']) ?   $data:$data['error'],
        ]);
    }

    protected function successReturn($data = [],$message="success",$error_code=0,$msg = 'success'){

        return response()->json([
            'error_code'=>$error_code,
            'data'=>$data,
            'msg'=>$msg,
            'error_msg' => $message,
        ]);
    }
}
